<template>
  <div class="app-layout">
    <div class="side-menu">
      <div class="side-menu-logo">
        <img src="/logo.svg" alt="logo" />
      </div>
      <div class="menu-list">
        <div
          v-for="menu in menus"
          :key="menu.path"
          class="menu-item"
          :class="{ active: route.path === menu.path }"
          @click="goMenu(menu.path)"
        >
          {{ menu.label }}
          <img
            v-if="route.path === menu.path && menu.path !== '/start/login'"
            src="/wave.svg"
            class="menu-wave"
            alt="wave"
          />
        </div>
      </div>
    </div>
    <div class="main-area">
      <router-view />
    </div>
  </div>
</template>

<script setup>
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();

const menus = [
  { label: "开始答题", path: "/start/login" },
  { label: "结果页", path: "/start/result" },
  { label: "其他页", path: "/start/other" },
  // 可继续添加更多菜单项
];

function goMenu(path) {
  if (route.path !== path) {
    router.push(path);
  }
}
</script>

<style scoped>
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: #f8f9fb;
  min-width: 320px;
  min-height: 100vh;
}
.side-menu {
  width: 128px;
  background: #2468f2;
  box-shadow: 2px 0 8px 0 rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 32px;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 10;
  border-radius: 0 0 0 0;
  overflow: visible;
}

.menu-item {
  width: 72px;
  height: 56px;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 16px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s,
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 400;
  gap: 6px;
  position: relative; /* 让子元素绝对定位基于此 */
}
.menu-item:hover {
  transform: scale(1.08);
  background: #3a7bfa;
}

.menu-item.active {
  background: #fff;
  color: #2468f2;
  font-weight: bold;
  box-shadow: 0 2px 8px 0 rgba(36, 104, 242, 0.08);
  transform: scale(1.12);
  position: relative;
}
.side-menu-logo {
  width: 40px;
  height: 40px;
  margin-bottom: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.main-area {
  flex: 1;
  overflow: auto;
  position: relative;
  margin-left: 140px;
  height: 100vh;
  overflow-y: auto;
  /* 隐藏滚动条 */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}
.main-area::-webkit-scrollbar {
  width: 0 !important;
  background: transparent;
}
.menu-wave {
  position: absolute;
  right: -30px; /* 可根据实际情况调整 */
  top: 50%;
  transform: translateY(-50%);
  width: 24px; /* 可根据实际情况调整 */
  height: auto;
  pointer-events: none;
  color: #f8f9fb;
  fill: #f8f9fb;
  animation: wave-fade 0.6s ease-out 1 forwards;
}

@keyframes wave-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
</style>
